<?php
//
// +------------------------------------------------------------------------+
// | PHP Version 5.4                                                        |
// +------------------------------------------------------------------------+
// | Copyright (c) All rights reserved.                                     |
// +------------------------------------------------------------------------+
// | 世纪车来车往(北京）网络科技有限公司 版权所有！                         |
// | TEL:010-63732365  HOTLINE:400-6688-365  EMAIL:clcw@clcw.com.cn         |
// | $Revision: 1.0 $                                                       |
// +------------------------------------------------------------------------+
// | Author: songaimin@clcw.com.cn  Blog:http://blog.csdn.net/samxx8        |
// +------------------------------------------------------------------------+
//

namespace AuctionCore\AuctionOrder;
use AuctionCore\System\AuctionException;

/**
* 拍单车商人工确认
* @author       Eric Lee
*/
class DealerConfirm {
      private $order_id = null;
      private $dealer_id = null;
    /**
    * 构造
    * @param    int $order_id    拍单编号
    * @param    int $dealer_id    拍单编号
    * @return   void
    */
    public function __construct($order_id,$dealer_id) {
           $this->order_id = $order_id;
           $this->dealer_id = $dealer_id;
    }
    
    /**
    * 同意收车
    * @return   boolean
    */
    public function agree() {
        if(empty($this->order_id)){
            AuctionException::make_throw('700002');
        }
        if(empty($this->dealer_id)){
            AuctionException::make_throw('500001');
        }
        $data = array();
        $data['order_id'] = $this->order_id;
        $data['dealer_id'] = $this->dealer_id;
        $data['next_trace_time'] = '';
        $data['remark'] = '';
        $data['result'] = '1';
        $data['createtime'] = date('Y-m-h H:i:s');
        return M('dealer_confirm_log')->add($data);
    }
    
    /**
    * 车商违约
    * @param    string $remark    备注
    * @return   boolean
    */
    public function break_auction($remark) {
           if(empty($this->order_id)){
               AuctionException::make_throw('700002');
           }
           if(empty($this->dealer_id)){
               AuctionException::make_throw('500001');
           }
           if(empty($remark)){
               AuctionException::make_throw('500009');
           }
           $data = array();
           $data['order_id'] = $this->order_id;
           $data['dealer_id'] = $this->dealer_id;
           $data['next_trace_time'] = '';
           $data['remark'] = $remark;
           $data['result'] = '3';
           $data['createtime'] = date('Y-m-h H:i:s');
           return M('dealer_confirm_log')->add($data);
    }
    
    /**
    * 继续跟踪
    * @param    string $reason    继续跟踪原因
    * @param    string $time    下次跟踪时间
    * @return   boolean
    */
    public function con_trace($reason, $time) {
            if(empty($this->order_id)){
                AuctionException::make_throw('700002');
            }
            if(empty($this->dealer_id)){
                AuctionException::make_throw('500001');
            }
            if(empty($reason)){
                AuctionException::make_throw('500010');
            }
            if(empty($time)){
                AuctionException::make_throw('500011');
            }
            $data = array();
            $data['order_id'] = $this->order_id;
            $data['dealer_id'] = $this->dealer_id;
            $data['next_trace_time'] = $time;
            $data['remark'] = $reason;
            $data['result'] = '2';
            $data['createtime'] = date('Y-m-h H:i:s');
            return M('dealer_confirm_log')->add($data);
    }
}

?>